using System;
using System.Linq;
using Arcane.Source.Combat;
using Arcane.Source.Utils;
using Godot;

namespace Arcane.Source.Story
{
    public class StoryContext : ViewContext<StoryView>
    {
        public override string ViewName => "story";
        public IChapter chapter;
        public Player player;

        // public DeferedEventStroage<StoryContext, > deferedEvents = new();

        public override void OnLoad(Msg msg)
        {
            player = new Player();
            base.OnLoad(msg);
        }

        public override void OnUnload()
        {
            base.OnUnload();

        }

        public void PrepareCombat(Action<StringName[]> OnDone)
        {
            View.ShowCombatPrepre(OnDone);
        }

        public IDialogHandler BeginDialog(Dialog dialogRoot)
        {
            var handler = View.HandleDialog();
            handler.ProcessTransition += trans =>
            {
                handler.ShowDialog(trans.Transit(this));
            };
            handler.ShowDialog(dialogRoot);
            return handler;
        }
    }
}